#include <graphics.h>

int main()
{
	
    initgraph(640,640);
    setlinecolor(WHITE);
    setfillcolor(RED);
	int v_x[5]={1,2,1,1,1},v_y[5]={1,1,1,2,1};
	int p_x[5],p_y[5];
	int i;
    BeginBatchDraw();
	for(i=0;i<5;i++)
	{
    p_x[i]=rand()%400+40,p_y[i]=rand()%400+40;
	}
    while(1)
	{
	    for(i=0;i<5;i++)
		{
        circle(p_x[i],p_y[i],20);
        floodfill(p_x[i], p_y[i], WHITE);
        FlushBatchDraw();
		if((p_x[i]<=20)||(p_x[i]>=620))
		v_x[i]=-v_x[i];
	    if((p_y[i]<=20)||(p_y[i]>=640))
		v_y[i]=-v_y[i];
		p_x[i]=p_x[i]+v_x[i];
        p_y[i]=v_y[i]+p_y[i];
	
		}
		cleardevice();
    }

    EndBatchDraw();
    closegraph();

	return 0;
}